package com.bawei.newsapplication.view.activity.channel

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import coil.load
import com.ayvytr.adapter.smart
import com.bawei.coom.model.bean.fomm.AnswerCommentListBean
import com.bawei.coom.model.bean.fomm.AnswerListBean
import com.bawei.coom.model.bean.homm.ProblemListBean
import com.bawei.newsapplication.R
import com.bawei.newsapplication.base.BaseActivity
import com.bawei.newsapplication.databinding.ActivityAnswerCommentListBinding
import com.bawei.newsapplication.viewmodel.MessageViewModel
/**
 * 作者: 谢庆平
 * 时间: 2024/10/31 14:24
 * 描述:查询回答的评论列表 
 */
class  AnswerCommentListActivity : BaseActivity<MessageViewModel,ActivityAnswerCommentListBinding>(R.layout.activity_answer_comment_list) {
    var  problemListAdapter=smart(mutableListOf<AnswerCommentListBean.Result>(),R.layout.problemlist_item,{ item, position ->
        findViewById<ImageView>(R.id.problemListImage).load(item.headPic)
        Log.i("item",item.headPic)
        findViewById<TextView>(R.id.problemListTitle).text=item.commentContent
        Log.i("item",item.commentContent)
        findViewById<TextView>(R.id.problemListName).text=item.nickName
        Log.i("item",item.nickName)
    }){}

    override fun initView() {
        mDataBinding.ivBackck.setOnClickListener { finish() }
        val intExtra = intent.getIntExtra("answerId", 0)
        Log.i("intExtra", intExtra.toString())

        mViewModel.getAnswerCommentList(intExtra,1,10)
        mDataBinding.rvAnswer.adapter=problemListAdapter
        mDataBinding.rvAnswer.layoutManager=androidx.recyclerview.widget.LinearLayoutManager(this)
    }

    override fun dataObserve() {
        mViewModel.answerCommentListData.observe(this,{
            problemListAdapter.update(it.result)
            Log.i("item",it.result.toString())
        })
    }

}